import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    num:1,
    name:'Giles'
  },
  getters: {
    showNum(state){
      return `数据已经跟新到了${state.num}`
    }
  },
  mutations: {
    incrementN(state,n){
      state.num+=n
    }
  },
  actions: {
    incrementAsync(cxt,n){
      setTimeout(() => {
        cxt.commit('incrementN',n)
      }, 3000);
    }
  },
  modules: {
  }
})
